@extends('layouts.back_stage')
@section('style')
    @parent
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/waveband.css?v0.1.8" rel="stylesheet">
    <link rel="stylesheet" href="{{env('CDN_DOMAIN_NAME')}}/css/createPro.css"/>
@endsection
@section('content')
<div class="head-box">
    <div class="head-title" style="margin-top:20px;">
        <h3>波段概览</h3>
    </div>
    <div class="head-bottom" style="margin-top:20px;">
        <a href="fabric" style="display:none;"><button class="btn btn-success">面辅料到货时间</button></a>
        <a href="exhibitgoodsTimes" style="display:none;"><button class="btn btn-success">上货时间表</button></a>
        <a href="addWaveband"><button class="btn btn-primary">添加波段</button></a>
    </div>
</div>
<ul class="form_ul index_form_ul">
    <form action="">
    <li class="form_li" style="width:230px;">
        <b>品牌:</b>
        <select name="brand" class="sel_inp">
            @if($where->brand)
            <option value="{{ $where->brand }}">{{ $brands[$where->brand] }}</option>
                @endif
                <option value="">请选择</option>
                @foreach($brands as $k=>$v)
                <option value="{{ $k }}">{{ $v }}</option>
                    @endforeach

        </select>
    </li>
    <li class="form_li" style="width:230px;">
        <b>波段名:</b>
        <input type="text" name="band_name" value="{{ $where->band_name }}" class="form-control">
    </li>
    <li class="form_li" style="width:230px;">
        <b>BOM版本:</b>
        <select name="bom" class="sel_inp">
            @if($where->bom)
                <option value="{{$where->bom}}">Bom {{$where->bom}}</option>
            @endif
            <option value="">全部</option>
            <option value="1.0v">Bom v1.0</option>
            <option value="2.0v">Bom v2.0</option>
        </select>
    </li>
    <li class="form_li">
        <input type="submit" value="搜索" class="btn btn-info" style="width:54px;">
    </li>
    </form>
</ul>
<div class="column-box">
    <ul>
        @if(count($bands) > 0)
            @foreach($bands as $k=>$v)
                <li>
                    <div class="waveband-name">
                        <p>{{ $v->title }}</p>
                    </div>
                    <div class="time-line">
                        <p>{{ $v->start_at }}</p>
                    </div>
                    <dl>
                        @if(count($info) > 0 )
                            @foreach($info as $ks=>$vs)
                                @if($v->title == $vs->title)
                                        <dd id="{{ $vs->id }}">
                            <div class="clothes-info">
                                @if(count($datas) > 0)
                                    @foreach($datas as $data)
                                        @if($data->band_id == $vs->id)
                                            @if($data->status == -1)
                                            <div class="clothes-brand-box waste-brand">
                                                @else
                                            <div class="clothes-brand-box">
                                            @endif
                                    <p>{{ $category[$data->cate1] }}:<a href="griardInfo?girard={{ $data->girard }}">{{ $data->girard }}</a></p>
                                    <p>搭配颜色：{{ $data->color }}{{ $data->bom }}</p>
                                </div>
                                        @endif
                                    @endforeach
                                @endif
                            </div>
                            <form id="uploadSubmit">
                            <div class="clothes-img">
                                <img src="{{ env('CDN_DOMAIN_NAME') }}/upload/{{$vs->img}}" class="showImg" alt="">
                            </div>
                            </form>
                            <div class="tool-box" id="{{ $vs->id }}">
                                <button class="trash"></button>
                                <a href="addMatch?id={{ $vs->id }}"><button class="amend"></button></a>
                            </div>
                        </dd>
                                @endif
                            @endforeach
                        @endif
                            <dd id="{{ $v->title }}">
                                <button class="btn btn-primary brandBom—addNews">添加新搭配</button>
                            </dd>
                    </dl>
                </li>
            @endforeach
            @endif
    </ul>
</div>
<div class="mask-box" onclick="closeImg()">
    <img onclick="closeImg()" src="" alt="">
</div>

<script>
    //动态高度
    $('.column-box ul li dl').css('max-height',window.innerHeight-260);
    //全屏看图
    $('.showImg').click(function () {
        var imgHref = $(this).attr('src');
        $('.mask-box img').attr('src',imgHref);
        $('.mask-box').show();
    });
    function closeImg(){
        $(".mask-box").hide();
    }
    //删除搭配
    $('.trash').click(function () {
        var that_ = $(this);
        var matchID = that_.parent().attr('id');
        $(".oText").text("确定要删除吗？");
        $(".oMask").show();
        $(".oAnim").show();
        $(".oBtn0").attr('id','');
        $(".oBtn0").attr('id','oRefund');
        $(document).on('click','#oRefund',function(){
            $(".oMask").hide();
            $(".oAnim").hide();
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                url:'/waveband/updateBandStatus',
                type:'post',
                dataType:'json',
                data:{
                    id:matchID
                },
                success:function (event) {
                    if(event.success = 'true'){
                        if(that_.parent().parent().siblings().length >1){
                            that_.parent().parent().remove();
                        }else{
                            that_.parent().parent().parent().parent().remove();
                        }
                        $(".faceImg").attr("src","/img/laugh.png");
                        $(".oHandle").text("删除成功");
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            })
        });
    });
    //添加新的搭配
    $('.brandBom—addNews').click(function () {
        var getWaveName = $(this).parent().attr('id');
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
            },
            url:'/waveband/increaseBand',
            type:'post',
            dataType:'json',
            data:{
                title:getWaveName
            },
            success:function(event){
                var matchID = event.info
                window.location.href="addMatch?id="+matchID
            }
        })
    });
</script>
@endsection
@section('script')
    @parent
@endsection